<%= form_for(@user, url: (@form_url || staff_path(@user))) do |f| %>
    <% if @user.errors.any? %>
        <div id="error_explanation">
          <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

          <ul>
            <% @user.errors.full_messages.each do |message| %>
                <li><%= message %></li>
            <% end %>
          </ul>
        </div>
    <% end %>

    <div><%= f.label :email %><br/>
      <%= f.email_field :email, required: true %></div>

    <div><%= f.label :password %><br/>
      <%= f.password_field :password %></div>

    <div><%= f.label :password_confirmation %><br/>
      <%= f.password_field :password_confirmation %></div>

    <div><%= f.label :name %><br/>
      <%= f.text_field :name, required: true %></div>

    <div><%= f.label :phone %><br/>
      <%= f.text_field :phone %></div>

    <div><%= f.label :wechat %><br/>
      <%= f.text_field :wechat %></div>

    <div><%= f.label :role %><br/>
    <%= f.select :role, [['员工', 'staff'], ['操作员', 'manager']] %></div>

    <div class="actions m-t-10">
      <%= link_to '取消', staffs_path, class: 'btn btn-default' %>
      <%= f.submit '保存', class: 'btn btn-primary' %>
    </div>
<% end %>

<% content_for(:javascript) do %>
<script>
  $(function(){
    $('form').validate();
  });
</script>
<% end %>